# eric7.EricGraphics.EricGraphicsView

Module implementing a canvas view class.

### Global Attributes

None

### Classes

EricGraphicsView | Class implementing a graphics view.

### Functions

None

## EricGraphicsView

Class implementing a graphics view.

### Signals

zoomValueChanged(int)
  emitted to signal a change of the zoom value

### Derived from

QGraphicsView

### Class Attributes

ZoomLevelDefault
ZoomLevels

### Class Methods

None

### Methods

EricGraphicsView | Constructor
__getDiagram | Private method to retrieve the diagram from the scene fitting it in the minimum rectangle.
__levelForZoom | Private method determining the zoom level index given a zoom factor.
_getDiagramRect | Protected method to calculate the minimum rectangle fitting the diagram.
_getDiagramSize | Protected method to calculate the minimum size fitting the diagram.
autoAdjustSceneSize | Public method to adjust the scene size to the diagram size.
filteredItems | Public method to filter a list of items.
getBackgroundColor | Public method to get the configured background color.
getDrawingColors | Public method to get the configured drawing colors.
getForegroundColor | Public method to get the configured foreground color.
printDiagram | Public method to print the diagram.
resizeScene | Public method to resize the scene.
saveImage | Public method to save the scene to a file.
setSceneSize | Public method to set the scene size.
setZoom | Public method to set the zoom value in percent.
zoom | Public method to get the current zoom factor in percent.
zoomIn | Public method to zoom in.
zoomOut | Public method to zoom out.
zoomReset | Public method to handle the reset the zoom value.

### Static Methods

None

#### EricGraphicsView (Constructor)

EricGraphicsView(scene, drawingMode="automatic", parent=None)

Constructor

scene (QGraphicsScene)
  reference to the scene object
drawingMode (str (optional))
  name of the drawing mode (one of "automatic", "black_white" or "white_black") (defaults to "automatic")
parent (QWidget)
  parent widget

#### EricGraphicsView.__getDiagram

__getDiagram(rect, imageFormat="PNG", filename=None)

Private method to retrieve the diagram from the scene fitting it in the minimum rectangle.

rect (QRectF)
  minimum rectangle fitting the diagram
imageFormat (str)
  format for the image file
filename (str)
  name of the file for non pixmaps

Return:
  paint device containing the diagram

Return Type:
  QPixmap or QSvgGenerator

#### EricGraphicsView.__levelForZoom

__levelForZoom(zoom)

Private method determining the zoom level index given a zoom factor.

zoom (int)
  zoom factor

Return:
  index of zoom factor

Return Type:
  int

#### EricGraphicsView._getDiagramRect

_getDiagramRect(border=0)

Protected method to calculate the minimum rectangle fitting the diagram.

border (int)
  border width to include in the calculation

Return:
  the minimum rectangle

Return Type:
  QRectF

#### EricGraphicsView._getDiagramSize

_getDiagramSize(border=0)

Protected method to calculate the minimum size fitting the diagram.

border (int)
  border width to include in the calculation

Return:
  the minimum size

Return Type:
  QSizeF

#### EricGraphicsView.autoAdjustSceneSize

autoAdjustSceneSize(limit=False)

Public method to adjust the scene size to the diagram size.

limit (bool)
  flag indicating to limit the scene to the initial size

#### EricGraphicsView.filteredItems

filteredItems(items)

Public method to filter a list of items.

items (QGraphicsItem)
  list of items as returned by the scene object

Return:
  list of interesting collision items

Return Type:
  QGraphicsItem

#### EricGraphicsView.getBackgroundColor

getBackgroundColor(drawingMode="automatic")

Public method to get the configured background color.

drawingMode (str (optional))
  name of the drawing mode (one of "automatic", "black_white" or "white_black") (defaults to "automatic")

Return:
  background color

Return Type:
  QColor

#### EricGraphicsView.getDrawingColors

getDrawingColors(drawingMode="automatic")

Public method to get the configured drawing colors.

drawingMode (str (optional))
  name of the drawing mode (one of "automatic", "black_white" or "white_black") (defaults to "automatic")

Return:
  tuple containing the foreground and background colors

Return Type:
  tuple of (QColor, QColor)

#### EricGraphicsView.getForegroundColor

getForegroundColor(drawingMode="automatic")

Public method to get the configured foreground color.

drawingMode (str (optional))
  name of the drawing mode (one of "automatic", "black_white" or "white_black") (defaults to "automatic")

Return:
  foreground color

Return Type:
  QColor

#### EricGraphicsView.printDiagram

printDiagram(printer, margins=None, diagramName="")

Public method to print the diagram.

printer (QPrinter)
  reference to a ready configured printer object
margins (QMarginsF or None (optional))
  diagram margins (defaults to None)
diagramName (str)
  name of the diagram

#### EricGraphicsView.resizeScene

resizeScene(amount, isWidth=True)

Public method to resize the scene.

amount (int)
  size increment
isWidth (bool)
  flag indicating width is to be resized

#### EricGraphicsView.saveImage

saveImage(filename, imageFormat="PNG")

Public method to save the scene to a file.

filename (float)
  name of the file to write the image to
imageFormat (float)
  format for the image file

Return:
  flag indicating success

Return Type:
  bool

#### EricGraphicsView.setSceneSize

setSceneSize(width, height)

Public method to set the scene size.

width (float)
  width for the scene
height (float)
  height for the scene

#### EricGraphicsView.setZoom

setZoom(value)

Public method to set the zoom value in percent.

value (int)
  zoom value in percent

#### EricGraphicsView.zoom

zoom()

Public method to get the current zoom factor in percent.

Return:
  current zoom factor in percent

Return Type:
  int

#### EricGraphicsView.zoomIn

zoomIn()

Public method to zoom in.

#### EricGraphicsView.zoomOut

zoomOut()

Public method to zoom out.

#### EricGraphicsView.zoomReset

zoomReset()

Public method to handle the reset the zoom value.

Up